package com.example.demo.model.converter;

import com.example.demo.model.core.PageVo;
import com.example.demo.model.entity.SysUser;
import com.example.demo.model.form.UserForm;
import com.example.demo.model.vo.LoginUserVO;
import com.example.demo.model.vo.UserProfileVO;
import com.example.demo.model.vo.UserVO;
import com.example.demo.security.model.UserAuthCredentials;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;
import java.util.Set;

@Mapper(componentModel = "spring")
public interface SysUserConverter {

    SysUser toEntity(UserForm roleForm);

    UserForm toForm(SysUser entity, List<String> roleIds);

    PageVo<UserVO> toPageVo(PageVo<SysUser> pageVo);

    UserVO toVo(SysUser value);

    LoginUserVO toLoginUser(SysUser entity, Set<String> roles,Set<String> perms);

    UserProfileVO toUserProfileVO(SysUser entity, String roleNames, String deptName);

    @Mapping(target = "password", source = "entity.password")
    @Mapping(target = "userId", source = "entity.id")
    @Mapping(target = "username", source = "entity.username")
    @Mapping(target = "nickname", source = "entity.nickName")
    @Mapping(target = "deptId", source = "entity.deptId")
    @Mapping(target = "status", source = "entity.status")
    @Mapping(target = "roles", source = "roles")
    UserAuthCredentials toUserAuthCredentials(SysUser entity, Set<String> roles);
}
